# class Solution:
#     def maxArea(self, height: list[int]) -> int:
#         max=0
#         for n in range(len(height)-1):
#             for i in range(n+1,len(height)):
#                 area=min(height[n],height[i])*(i-n)
#                 if(area>max):
#                     max=area
#
#         return max
"""
双指针移动，谁小 谁向里面移动
"""


class Solution:
    def maxArea(self, height: list[int]) -> int:
        max = 0
        n = 0
        i = len(height) - 1

        while (i > n):
            area = min(height[n], height[i]) * (i - n)
            if (area > max):
                max = area
            if (height[n] < height[i]):
                n += 1
            else:
                i -= 1
        return max


lll = Solution()

print(lll.maxArea([1, 8, 6, 2, 5, 4, 8, 3, 7]))
